<!-- 底部 -->
<div class="footer">
    <nav class="footer-bar">
        <div class="tab-item">
            <a href="{:url('/')}">
                <span class="mui-icon mui-icon-home"></span>
                <span class="mui-tab-label">首页</span>
            </a>
        </div>
        <div class="tab-item">
            <a href="{:url('/home/subject/subject/search')}">
                <span class="mui-icon mui-icon-search"></span>
                <span class="mui-tab-label">搜索</span>
            </a>
        </div>
        <div class="tab-item">
            <a href="{:url('/home/business/index')}">
                <span class="mui-icon mui-icon-contact"></span>
                <span class="mui-tab-label">我的</span>
            </a>
        </div>
    </nav>
</div>

<script>
    // 把获取到地址转成数组
    let pathArr = location.pathname.split('/');

    // 过滤掉空元素
    pathArr = pathArr.filter((value) => {
        return value && value.trim();
    });

    // 重组路径
    let path = pathArr.slice(0, 2).join('/');

    if (path === '' || path === '/') {
        $('.tab-item').eq(0).addClass('mui-active');
    } else if (path === 'home/subject') {
        $('.tab-item').eq(1).addClass('mui-active');
    } else if (path === 'home/business') {
        $('.tab-item').eq(2).addClass('mui-active');
    }
</script>